package ru.st.selenium;

import java.util.regex.Pattern;
import java.util.concurrent.TimeUnit;
import org.testng.*;
import org.testng.annotations.*;
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;

public class StoringElements_1 extends ru.st.selenium.pages.TestBase {
private boolean acceptNextAlert = true;
private StringBuffer verificationErrors = new StringBuffer();

@Test
public void testUntitled () throws Exception {    driver.get(baseUrl + "/chapter1");
    String textOnThePage = driver.findElement(By.id("divontheleft")).getText();
    // ERROR: Caught exception [Error: locator strategy either id or name must be specified explicitly.]
    
    driver.findElement(By.id("storeinput")).sendKeys(textOnThePage);
	}

private boolean isElementPresent (By by) {
  try {
    driver.findElement (by);
    return true;
    } catch (NoSuchElementException e) {
       return false;
    }
  }

private String closeAlertAndGetItText() {
  try {
    Alert alert = driver.switchTo().alert();
    String alertText = alert.getText();
    if (acceptNextAlert) {
      alert.accept();
    } else {
       alert.dismiss();
    } 
    return alertText;
    } finally {
      acceptNextAlert = true;
    }
   }
  }
